home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 07 - 1991 / 07.06 Jun 91 / Set Net Clocks Code / SetTimeDate.p < prev    next >
Encoding:
Text File  |  1991-04-04  |  1.2 KB  |  43 lines  |  [TEXT/PJMM]

  1. { HyperCard SetTimeDate XCMD    }
  2. { by Dave Kelly                              }
  3.  
  4. unit SetTimeDateUnit;  { This project handles the SetTimeDate command }
  5. interface
  6.     uses  { include the HyperCard interfaces in the XFCN/CMD }
  7.         HyperXCmd;
  8.  
  9.     procedure main (paramPtr: XCmdPtr);  { the entry point for the XCMD/XFCN }
  10.  
  11. implementation
  12.  
  13.     procedure main;
  14.  
  15.         procedure Fail (errMsg: Str255); { return a given error message to HyperCard }
  16.         begin
  17.             paramPtr^.returnValue := PasToZero(paramPtr, errMsg);
  18.         {Set the return value of the paramBlock to the given message. }
  19.             exit(main); {exit the routine }
  20.         end;
  21.  
  22.         procedure Setthetime (paramPtr: XCmdPtr);
  23.             var
  24.                 str: str255;
  25.                 TheTimeDate: longint;
  26.                 Error: OSErr;
  27.  
  28.         begin
  29.             if (paramPtr^.paramCount <> 1) then
  30.                 Fail('%bad parameters');
  31.  
  32.             ZeroToPas(paramPtr, paramPtr^.params[1]^, str);  { convert the location to a string }
  33.             TheTimeDate := StrToNum(paramPtr, str);            { and thence to a longint }
  34.             Error := SetDateTime(TheTimeDate);
  35.             { if the handle is empty, then return an error}
  36.             if Error <> noErr then
  37.                 Fail('DateTime not changed!');
  38.         end;
  39.  
  40.     begin
  41.         Setthetime(paramPtr);  {entry point; call the Setthetime routine}
  42.     end;
  43. end.